package com.games.game.controller;

import com.games.game.bean.Game;
import com.games.game.service.Game_Service;
import com.games.game.service.User_Game_Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class GameController {
    @Autowired
    private Game_Service game_service;
    @Autowired
    private User_Game_Service user_game_service;

    @RequestMapping(value = "games", method = RequestMethod.GET)
    public List<Game> get_all_games() {
        return game_service.get_all_games();
    }
    // 得到游戏库所有游戏

    @RequestMapping(value = "games/search", method = RequestMethod.GET)
    public Game get_cer_games(@RequestParam(value = "name") String name) {
        return game_service.get_cer_games(name);
    }
    // 从游戏库中搜索特定游戏

    @RequestMapping(value = "games/recommend", method = RequestMethod.GET)
    public List<Game> get_cer_num_games(int num) {
        return game_service.get_cer_num_games(num);
    }
    // 从游戏库中得到一定数量的游戏来推荐

    @RequestMapping(value = "games/category/{type}", method = RequestMethod.GET)
    public List<Game> get_cer_type_games(@PathVariable(value="type") String type) {
        return game_service.get_cer_type_games(type);
    }
    // 从游戏库中得到特定类型的游戏
}
